package cn.cvs;

import cn.cvs.dao.StorageRecordMapper;
import cn.cvs.entity.StorageRecord;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@SpringJUnitConfig(locations = "classpath:applicationContext.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class StorageTestConn {
    /**
     * @description:查询用户测试
     * @author: liu xi 
     * @param: * @param null
     * @date: 2025/4/15 19:39 
     * @return: 
     */
    @Autowired
    private StorageRecordMapper recordMapper;
    @Test
    public void testSelPage(){
        //获取列表
        List<StorageRecord> userList =recordMapper.selectList(null,null,null,0,5);
        //获取总条数
        int count = recordMapper.selectCount(null,null,null);

    }
    /** 根据ID查询入库记录信息
     * @param
     * @return null
     * @author Lenovo
     * @date 2025/5/21
     * @time 15:55
     */
    @Test
    public void testSelectById() {
        Integer id = 1;
        StorageRecord storageRecord = recordMapper.selectById(id);
        if (storageRecord != null) {
            System.out.println("查询到的入库记录信息: " + storageRecord);
        } else {
            System.out.println("未查询到对应id的入库记录");
        }
    }

    /** 根据用户ID删除入库记录信息
     * @param
     * @return null
     * @author Lenovo
     * @date 2025/5/21
     * @time 16:47
     */
    @Test
    public void testDeleteById() {
        Integer id = 1;
        int affectedRows = recordMapper.deleteById(id);
        if (affectedRows > 0) {
            System.out.println("成功删除入库记录，受影响行数: " + affectedRows);
        } else {
            System.out.println("删除入库记录失败，受影响行数: " + affectedRows);
        }
    }

    @Test
    public void testselAll(){
//    List<StorageRecord> recordList=recordMapper.selAll("百",2,"已支付");
//    for(StorageRecord record:recordList){
//        System.out.println(
//                record.getSrCode()+"--"+
//                record.getGoodsName()+"--"+
//                record.getTotalAmount()+"--"+
//                record.getSupName()+"--"+
//                record.getPayStatus()+"--"+
//                record.getCreatedTime()
//        );
//    }
}
}
